package com.firstwave.sfreading.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.net.URI;

/**
 * @Author: shafei
 * @Date: 2020-06-01 11:10
 * @Version: V1.0
 * @Description:
 */
@Service
public class BookService {

    @HystrixCommand(fallbackMethod = "reliable")
    public String readingList(){
        RestTemplate restTemplate = new RestTemplate();
        URI uri = URI.create("http://localhost:3333/recommonded");
        String res = restTemplate.getForObject(uri,String.class);
        return res;
    }

    /**
     * 回调函数
     * @return
     */
    public String reliable(){
        return "Cloud reload";
    }

}
